﻿using System;
namespace HomeWork3 {

    public delegate void ClockDelegate();
    public class Clock{
        public event ClockDelegate alarm;
        public event ClockDelegate tick;
        public bool isAlarm;
        public bool isTick;
        public Clock(bool isAlarm, bool isTick)
        {
            this.isAlarm = isAlarm;
            this.isTick = isTick;
        }
    
        public void AlarmTrigger() {
            alarm?.Invoke();
        }
        public void TickTrigger() {
            tick?.Invoke();
        }
    }

    public class ClockTest { 
    
        public static void Main(string[] args) {
            Clock clock = new Clock(true,true);
            clock.alarm += () => Console.WriteLine("闹钟响了");
            clock.tick+= () => Console.WriteLine("闹钟正在走");
            if (clock.isTick) {
                clock.TickTrigger();
            }
            if (clock.isAlarm) { 
                clock.AlarmTrigger();
            }
        }
    }
}